import request from '@/plugin/axios'
import util from '@/libs/util.js'

export default {

	list (data) {
		return request({
			url: 'mchaccountaccesstype/list',
			headers: {},
			method: 'post',
			data,
		});
	},

	info (data) {
		return request({
			url: 'mchaccountaccesstype/info',
			headers: {},
			method: 'post',
			data,
		});
	},

	add (data) {
		return request({
			url: 'mchaccountaccesstype/add',
			headers: {},
			method: 'post',
			data,
		});
	},

	set (data) {
		return request({
			url: 'mchaccountaccesstype/set',
			headers: {},
			method: 'post',
			data,
		});
	},

	getTypeOptions (data) {
		return request({
			url: 'mchaccountaccesstype/getTypeOptions',
			headers: {},
			method: 'post',
			data,
		});
	},

	getAccessTypeOptions (data = {}) {

		return new Promise ((resolve, reject) => {
			this.list(data)
			.then(re => {
				
				var options = [];

				re.list.forEach(item => {
					options.push({
						label: item.value,
						value: item.id,
					});
				});

				resolve(options);
			})
			.catch(err => reject(err));
		});
	},

};